import com.zzuli.dcxt.entiy.User;
import com.zzuli.dcxt.service.LoginService;
import javafx.application.Application;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:spring-mybatis.xml"})
public class test2 {
    //运行前的环境
    private ApplicationContext application;
    @Autowired
    private LoginService loginService=null;
    @Before
    public void before(){
        application=new ClassPathXmlApplicationContext("spring-mybatis.xml");
        loginService =(LoginService) application.getBean("loginService");
        System.out.println(loginService);
    }

    //测试登录
    @Test
    public void login(){

        User user = new User();
        user.setName("张三");
        user.setPassword("123456");
        User login = loginService.login(user);
        System.out.println("姓名："+login.getName()+"密码："+login.getPassword());
    }

}
